using Headspring.Training.Domain.Model;
using StructureMap;

namespace Headspring.Training.Domain.Services.Impl
{
	[Pluggable(Keys.DEFAULT)]
	public class WorkOrderBuilder : IWorkOrderBuilder
	{
		private readonly IWorkOrderNumberGenerator _numberGenerator;
		private readonly IClock _clock;

		public WorkOrderBuilder(IWorkOrderNumberGenerator numberGenerator, IClock clock)
		{
			_numberGenerator = numberGenerator;
			_clock = clock;
		}

		public WorkOrder CreateNewWorkOrder(Employee creator)
		{
			WorkOrder workOrder = new WorkOrder();
			workOrder.Number = _numberGenerator.GenerateNumber();
			workOrder.CreatedDate = _clock.GetCurrentTime();
			workOrder.Creator = creator;
			workOrder.Status = WorkOrderStatus.Draft;
			return workOrder;
		}
	}
}